<?php

class Hand {
  public $id;
  public $gameId;
  public $gameRoundId;
  public $playerId;
  public $card;
  
  
  public function __construct($id = null, $gameId = null)
  {
    $this->Init();

    if (!$this->Load($id, $gameId))
      $this->Init();
  }

  private function Init()
  {
    $this->id = -1;
    $this->gameId = -1;
    $this->gameRoundId = -1;
    $this->playerId = -1;
  }
  
  private function Load($id = null, $gameId = null)
  {
    if (!$this->LoadData($id, $gameId)) return false;
    return true;
  }
   
  public function Save()
  {
    $values = array();
    
    $values['game_id'] = intval($this->gameId);
    $values['dealer_id'] = intval($this->dealerId);
    $values['trump'] = $this->trump;
    $values['game_amount'] = $this->gameAmount;
    $values['status'] = $this->status;
    
    $oldHand = new Hand($this->id);
    if ($oldHand->id && $oldHand->id > 0)
    {
      $res = DB::table('hands')
              ->where('id', '=', $oldHand->id)
              ->update($values);
    }
    else
      $res = DB::table('hands')->insert($values);
  }
}
?>
